package com.vincenzoracca.webflux.mdc.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Vincenzo Racca
 */
@ConfigurationProperties(prefix = "spring.mdc")
@Data
public class SpringMDCProperties {


    /**
     * headers is a map: <HEADER_KEY, MDC_KEY>.
     * This variable is used by the {@link com.vincenzoracca.webflux.mdc.filter.MDCFilter}.
     * If the headers in the HTTP request contains the HEADER_KEY, then the MDC_KEY is added in the MDC.
     * <p>
     * Example usage: spring.mdc.headers.X-Amzn-Trace-Id=trace_id -> if the request headers contains the X-Amzn-Trace-Id,
     * then the value is added in MDC with trace_id key.
     */
    private Map<String, String> headers = new HashMap<>();

    /**
     * defaults is a list of HEADER_KEY. If the request headers doesn't contain the HEADER_KEY,
     * then the library add the MDC_KEY (retrieved by the headers variable) with a UUID generated by the library.
     * <p>
     * Example usage: spring.mdc.defaults=X-Amzn-Trace-Id -> if the request headers doesn't contain the X-Amzn-Trace-Id
     * key, then the library add the trace_id key to MDC with a UUID value.
     */
    private List<String> defaults = new ArrayList<>();}
